package com.youth.platform.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class DBConnection {
	/**
	 * 根据当前系统的数据库相关参数，获取该数据库连接
	 * @param userName 登陆名
	 * @param password 密码
	 * @param url 数据库访问URL
	 * @param driverClassName 驱动程序
	 * @return
	 */
	public static Connection getConnections(String userName,String password,String url,String driverClassName){
		
		Connection conn=null;
		   try {
			//加载数据库驱动程序
			Class.forName(driverClassName);
			//获取连接
			conn=DriverManager.getConnection(url,userName,password);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		   return conn;
		
	}
}
